<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>

<jsp:directive.page import="com.db.BaseDAO"/>

<%
	String path = request.getContextPath();
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="pragma" content="no-cache" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="expires" content="0" />
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3" />
<meta http-equiv="description" content="This is my page" />

<link rel="stylesheet" type="text/css" href="<%=path%>/css/base.css" />
<script>
	function check() {
	    var regy = /^\d+$/gi;
		var regx = /^\d+$/gi;
		var regs = /^\d+$/gi;
		var regName = /^[\u4e00-\u9fa5]{2,4}$/gi;
		
		var stuno = document.getElementById("stuno").value;
		var company = document.getElementById("company").value;
		var tel = document.getElementById("tel").value;
		var name = document.getElementById("name").value;
		if (!regy.test(stuno)) {
			alert("请输入正确的学号");
			return false;
		}
		if (!regx.test(company)) {
			alert("请输入正确的宿舍号");
			return false;
		}
		 if (!regName.test(name)) {
			alert("请输入正确的姓名");
			return false;
		} 
		if (!regs.test(tel)) {
			alert("请输入正确的号码");
			return false;
		}
		return true;
	}
</script>

</head>

<body leftmargin="2" topmargin="9"
	background='<%=path%>/images/allbg.gif'>
	<form action="<%=path%>/kuaijian!add.action" name="formAdd"
		method="post" onsubmit="return check();">
		<table width="98%" align="center" border="0" cellpadding="4"
			cellspacing="1" bgcolor="#CBD8AC" style="margin-bottom: 8px">
			<tr bgcolor="#EEF4EA">
				<td colspan="3" background="<%=path%>/images/wbg.gif" class='title'>
					<span>添加</span>
				</td>
			</tr>
			<tr align='center' bgcolor="#FFFFFF"
				onMouseMove="javascript:this.bgColor='red';"
				onMouseOut="javascript:this.bgColor='#FFFFFF';" height="22">
				<td width="25%" bgcolor="#FFFFFF" align="right">区域：</td>
				<td width="75%" bgcolor="#FFFFFF" align="left">
							<select name="data.area">
						  <%
						     BaseDAO dao = new BaseDAO();
						     List<Object[]> all = dao.find("select distinct area from flat",null);
						     for(Object[] data:all){
						   %>
						     <option><%=data[0]%></option>
						   <% } %>
						</select>
					</td>
			</tr>
			<tr align='center' bgcolor="#FFFFFF"
				onMouseMove="javascript:this.bgColor='red';"
				onMouseOut="javascript:this.bgColor='#FFFFFF';" height="22">
				<td width="25%" bgcolor="#FFFFFF" align="right">楼栋：</td>
				<td width="75%" bgcolor="#FFFFFF" align="left"><select
					name="data.flat">
						<option value="1">1</option>
						<option value="2">2</option>
						<option value="3">3</option>
						<option value="4">4</option>
						<option value="5">5</option>
						<option value="6">6</option>
						<option value="7">7</option>
						<option value="8">8</option>
				</select></td>
			</tr>
			<tr align='center' bgcolor="#FFFFFF"
				onMouseMove="javascript:this.bgColor='red';"
				onMouseOut="javascript:this.bgColor='#FFFFFF';" height="22">
				<td width="25%" bgcolor="#FFFFFF" align="right">学号：</td>
				<td width="75%" bgcolor="#FFFFFF" align="left"><input
					name="data.stuno" id="stuno" /></td>
			</tr>
			<tr align='center' bgcolor="#FFFFFF"
				onMouseMove="javascript:this.bgColor='red';"
				onMouseOut="javascript:this.bgColor='#FFFFFF';" height="22">
				<td width="25%" bgcolor="#FFFFFF" align="right">宿舍号：</td>
				<td width="75%" bgcolor="#FFFFFF" align="left"><input
					name="data.company" id="company" /></td>
			</tr>

			<tr align='center' bgcolor="#FFFFFF"
				onMouseMove="javascript:this.bgColor='red';"
				onMouseOut="javascript:this.bgColor='#FFFFFF';" height="22">
				<td width="25%" bgcolor="#FFFFFF" align="right">姓名：</td>
				<td width="75%" bgcolor="#FFFFFF" align="left"><input
					type="text" name="data.name" id="name" /></td>
			</tr>
			<tr align='center' bgcolor="#FFFFFF"
				onMouseMove="javascript:this.bgColor='red';"
				onMouseOut="javascript:this.bgColor='#FFFFFF';" height="22">
				<td width="25%" bgcolor="#FFFFFF" align="right">联系方式：</td>
				<td width="75%" bgcolor="#FFFFFF" align="left"><input
					name="data.tel" id="tel" /></td>
			</tr>
			<tr align='center' bgcolor="#FFFFFF"
				onMouseMove="javascript:this.bgColor='red';"
				onMouseOut="javascript:this.bgColor='#FFFFFF';" height="22">
				<td width="25%" bgcolor="#FFFFFF" align="right">类别：</td>
				<td width="75%" bgcolor="#FFFFFF" align="left"><input
					name="data.status" value="缺寝"/>
				</select></td>
			</tr>

			<tr align='center' bgcolor="#FFFFFF"
				onMouseMove="javascript:this.bgColor='red';"
				onMouseOut="javascript:this.bgColor='#FFFFFF';" height="22">
				<td width="25%" bgcolor="#FFFFFF" align="right">&nbsp;</td>
				<td width="75%" bgcolor="#FFFFFF" align="left"><input
					type="submit" value="提交" /> &nbsp; <input type="reset" value="重置" />
					&nbsp;</td>
			</tr>
		</table>
	</form>
</body>
</html>
